home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 099 (1989-05-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 099 (1989-05-15)(Ossowski, Stefan)(DE)(PD).adf / PCQ / Runtime / readln.asm < prev    next >
Assembly Source File  |  1989-03-31  |  817b  |  41 lines

  1.  
  2. *    ReadLn.asm (of PCQ Pascal runtime library)
  3. *    Copyright (c) 1989 Patrick Quaid
  4.  
  5. *    Implements readln....
  6.  
  7.     SECTION    ONE
  8.  
  9.     XREF    _p%readonechar
  10.     XREF    _p%getthatchar
  11.     XREF    stdinbuffed
  12.     XREF    stdinbuffer
  13.     XREF    _p%readarbbuf
  14.  
  15.     XDEF    _p%readln
  16. _p%readln
  17.  
  18. * top of stack has file
  19.  
  20.     move.l    4(sp),a0        ; get file record
  21.     move.l    a0,d0
  22.     bne    readlnfile        ; is not stdin, go around
  23. 1$    jsr    _p%readonechar        ; read a char
  24.     move.b    #0,stdinbuffed        ; un-buffer it
  25.     cmp.b    #10,stdinbuffer        ; is it LF?
  26.     bne.s    1$            ; go to read again
  27. 3$    rts                ; and return
  28.  
  29. readlnfile:
  30. 1$    tst.b    12(a0)            ; at eof?
  31.     bne.s    3$            ; if so, leave
  32.     move.b    4(a0),d0        ; get the next char
  33.     cmp.b    #10,d0            ; is it LF?
  34.     beq.s    2$            ; go to read one more
  35.     jsr    _p%readarbbuf        ; read next char
  36.     bra    1$            ; loop
  37. 2$    jsr    _p%readarbbuf        ; eat the LF
  38. 3$    rts                ; and return
  39.  
  40.     END
  41.